<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="lijinbo" />
    <title>grid_骰子-2</title>
    <style>
      .box li {
        width: 50px;
        height: 50px;
        padding: 4px;
        background-color: tomato;
        border-radius: 10%;
        margin: 6px;
        list-style: none;
      }
      .box .dot {
        display: inline-block;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background-color: white;
      }

      /* ===== grid ===== */
      .grid_max {
        display: flex;
      }
      .grid_max li {
        display: grid;
        place-items: center;
        grid-template: repeat(3, 1fr) / repeat(3, 1fr);
      }
    </style>
  </head>

  <body>
    <div id="app" class="box">
      <p>绘制9个格子，需要显示的格子添加 dot 样式</p>
      <ol class="grid_max"></ol>
    </div>
    <script>
      const olDom = document.querySelector('.grid_max')
      const list = [[5], [1, 9], [1, 5, 9], [1, 3, 7, 9], [1, 3, 5, 7, 9], [1, 3, 4, 6, 7, 9]]
      for (let item of list) {
        const li = document.createElement('li')
        for (let i = 1; i <= 9; i++) {
          const div = document.createElement('div')
          if (item.includes(i)) {
            div.className = 'dot'
          }
          li.append(div)
        }
        olDom.append(li)
      }
    </script>
  </body>
</html>
